package csel.model;

public class Direction implements java.io.Serializable
{
	private static final long serialVersionUID = 5L;
	/*assumes that coordinate  (0,0) is at upper left */
	public static final Direction NORTH     = new Direction(0, -1);
	public static final Direction NORTHEAST = new Direction(1, -1);
	public static final Direction EAST      = new Direction(1, 0);
	public static final Direction SOUTHEAST = new Direction(1, 1);
	public static final Direction SOUTH     = new Direction(0, 1);
	public static final Direction SOUTHWEST = new Direction(-1, 1);
	public static final Direction WEST      = new Direction(-1, 0);
	public static final Direction NORTHWEST = new Direction(-1, -1);
	
	private final int x;
	private final int y;
	private final int angle;
	
	protected Direction(int x, int y)
	{
		this.x = x;
		this.y = y;
		
		/* TODO: test this */
		this.angle = (int)Math.round((Math.atan2(x, y) * 180 / Math.PI));
	}
	
	public int getX()
	{
		return this.x;
	}
	
	public int getY()
	{	
		return this.y;
	}
	
	public int getAngle()
	{
		return this.angle;
	}

	public boolean equals(Direction d)
	{
		if (d.x == this.x && d.y == this.y)
		{
			return true;
		} else
		{
			return false;
		}
	}
}
